<!--
 * @Author: Lu junwen
 * @Date: 2022-04-08 10:31:23
 * @LastEditors: Lu junwen
 * @LastEditTime: 2022-04-28 11:46:46
 * @FilePath: \vue-shop-app-customer\src\components\orderCard.vue
-->
<template>
  <div>
    <div
      v-for="order in orderList"
      class="order"
      :key="order.order_id"
      @click="switchDetail(order.order_id)"
    >
      <div class="order_item">
        <div class="orderTop">
          <div class="time_box">
            <span class="order_time">{{order.create_time | dateFormat}}</span>
          </div>
          <div class="pay_box">
            <!-- <span
                      class="pay"
                      v-show="order.pay_status === '1'"
                      style="background:#e5eecc"
            >已支付</span>-->
            <span class="pay" v-show="order.pay_status === '0'" style="background:#e6aa7f">未支付</span>
          </div>
          <div class="send_box">
            <span
              class="send"
              v-show="order.is_send === '是' && order.pay_status === '1'"
              style="background:#e5eecc; color:#67c23a"
            >已发货</span>
            <span
              class="send"
              v-show="order.is_send === '否' && order.pay_status === '1'"
              style="background:#e6aa7f"
            >未发货</span>
          </div>
        </div>
        <div class="orderMiddle">
          <div class="order_middle_left">
            <img v-for="item in order.goods" :key="item.goods_id" :src="item.goods_pics" alt />
          </div>
          <div class="order_middle_right">
            <div class="order_price">
              ￥
              <span class="price">{{order.order_price}}</span>
            </div>
            <div class="cart_num">共{{order.goods_sum}}件</div>
          </div>
        </div>
        <div class="order_bottom" style="15px">
          <van-button
            color="linear-gradient(to right, #ff6034, #ee0a24)"
            size="small"
            round
            v-show="order.pay_status === '0'"
            @click.stop="change(order)"
          >立即支付</van-button>
          <van-button
            color="#7232dd"
            size="small"
            round
            v-show="order.is_send === '是'"
            @click.stop="showProgressDialog"
          >查询物流</van-button>
        </div>
      </div>
    </div>
    <van-empty v-if="this.length === 0" description="您没有订单" />
  </div>
</template>

<script>
export default {
  name: 'orderCard',
  props: {
    orderList: {
      type: Array,
      default: []
    },
    length: {
      type: Number,
      default: 0
    }
  },
  filters: {
    // ellipsis(value) {
    //   console.log(value,'adawd');
    //   let num = 0
    //   for (let index = 0; index < value.length; index++) {
    //     const element = value[index];
    //     num = num + element.goods_number
    //   }
    //   return num
    // }
  },
  methods: {
    //跳转订单详情页面
    switchDetail(id) {
      this.$router.push({
        path: "orderdetail",
        query: { id },
      });
    },
    change(order) {
      this.$emit('change', { isShow: true, order: order })
    },
    showProgressDialog() {
      this.$emit('showProgressDialog')
    }
  }
}
</script>

<style lang="scss" scoped>
.order {
  position: relative;
  margin: 15px 15px 15px 15px;
  /* box-shadow: 0 0 2px 3px #ccc; */
  /* border: 1px solid #ccc; */
  /* font-family: 黑体; */
  font-size: 15px;
  background-color: #f5f5f5;
  border-radius: 10px;
}
.order_item {
  position: relative;
  width: 95.5%;
  /* height: 87px; */
  /* margin: 7px 7px 7px 7px; */
  padding: 7px 7px 7px 15px;
  /* border: 1px solid black; */
}
.orderTop {
  position: relative;
  display: flex;
  width: 100%;
}
.order_time {
  font-size: 18px;
  font-weight: 600;
}
.send,
.pay {
  padding: 2px 4px;
  border-radius: 5px;
  font-size: 15px;
  color: #fff;
}
.pay {
  margin-left: 120px;
}
.send {
  margin-left: 40px;
}
.order_time:before {
  content: '';
  display: inline-block;
  padding: 7px 3px;
  margin-right: 5px;
  background-color: brown;
  border-radius: 3px;
}
.orderMiddle {
  position: relative;
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
}
.order_middle_left {
  position: relative;
  width: 280px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  overflow: -moz-scrollbars-none;
  &::-webkit-scrollbar {
    display: none;
    width: 0 !important
  }
}
.order_middle_right {
  display: flex;
  margin-top: 15px;
  margin-right: 15px;
  padding-left: 5px;
  height: 50px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-left: 1px solid #c7c7c7;
}
.order_price {
  font-size: 12px;
}
.price {
  font-size: 18px;
  color: red;
}
.cart_num {
  font-size: 14px;
  color: #949494;
}
.more {
  display: inline-block;
  height: 80;
  line-height: 80px;
  margin-left: 2px;
  font-size: 20px;
}
img {
  display: inline-block;
  height: 80px;
  width: 80px;
  border: 1px solid #c7c7c7;
  border-radius: 10px;
  vertical-align: middle;
}
img:nth-child(n + 2) {
  margin-left: 8px;
}
.order_bottom {
  position: relative;
  margin-top: 5px;
  margin-right: 10px;
  display: flex;
  justify-content: flex-end;
}
</style>